﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SugarWebApi
{

	public class SugarIndexResolver
	{

		#region Constructors

		/// <summary>
		/// 
		/// </summary>
		/// <param name="fields"></param>
		public SugarIndexResolver(
			string[] fields)
		{
			this._fields = fields;
		}

		#endregion

		#region Fields

		private string[] _fields;

		#endregion

		#region Properties

		public string[] Fields
		{
			get { return _fields; }
		}

		#endregion

		public int IndexOf(
			string fieldname)
		{
			return Array.IndexOf<string>(_fields, fieldname);
		}

		public int IndexOf(
			SugarField field)
		{
			if (field == null) return -1;
			return this.IndexOf(field.Name);
		}

	}
}
